<!--
*@ab-textarea
*@author lijiaqi
*@date 2024/1/22 9:46
-->
<template>
  <div class="textarea_box">
    <van-field
      v-model="inputValue"
      rows="1"
      :autosize="autosize"
      label=""
      type="textarea"
      :placeholder="placeholder"
      @input="changeValue"
      :max-length="maxlength"
      :disabled="disabled"
    />
  </div>
</template>

<script>
export default {
  name: "ab-textarea",
  props: {
    autosize: {
      type: Boolean,
      default: true
    },
    value: {
      type: String,
      default: ''
    },
    placeholder: {
      type: String,
      default: '请输入'
    },
    maxlength: {//最大长度
      type: String,
      default: ''
    },
    disabled: {//是否禁用
      type: Boolean,
      default: false
    },
    readonly: {//是否只读
      type: Boolean,
      default: false
    }
  },
  components: {},
  data() {
    return {
      inputValue: ''
    }
  },
  computed: {},
  watch: {
    value(newVal, oldVal) {
      this.inputValue = newVal
    },
  },
  created() {
    if (this.value) {
      this.inputValue = this.value
    }
  },
  mounted() {
  },
  methods: {
    /**
     *输入内容改变时
     * @param v
     */
    changeValue(v) {
      this.$emit('input', v)
    }
  }
}
</script>

<style lang="less" scoped>
/deep/ .van-cell {
  padding: 9px 0 !important;
  font-size: unset;
}

/deep/ .van-field__control:disabled {
  color: unset;
  -webkit-text-fill-color: unset;
}
</style>
